package com.qys.livesMall.open.mail.config;


import com.qys.livesMall.common.utils.SpringUtils;
import com.qys.livesMall.open.modal.entity.H2MailConfig;
import com.qys.livesMall.open.service.H2MailConfigService;
import com.qys.livesMall.open.service.impl.H2MailConfigServiceImpl;
import lombok.Data;
import org.springframework.beans.BeanUtils;

@Data
public class MailConfig {

    private String type;

    private String host;

    private String port;

    private String auth;
    /**
     * 发送者
     */
    private String sendUser;
    /**
     * 发送者名称
     */
    private String sendName;


    private String starttlsEnable;
    /**
     * 账号
     */
    private String userName;
    /**
     * 密码
     */
    private String password;

    private H2MailConfigService service;

    private volatile static MailConfig mailConfig =null;

    private MailConfig(){
       service = SpringUtils.getBean(H2MailConfigServiceImpl.class);
        H2MailConfig mallMailConfig=service.getConfig();
        BeanUtils.copyProperties(mallMailConfig,this);
    }
//
    public static MailConfig get(){
        if (mailConfig==null){
            mailConfig=new MailConfig();
        }
        return mailConfig;
    }


}
